package com.lonely.fx.spinner;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Spinner;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**
 * @date: 2022-07-19 21:16
 * @author: ztkj-hzb
 * @description: 文本框(类似h5的数字框效果) --  基于一个list
 **/
public class SpinnerWithListSettingMain extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        HBox hBox = new HBox();

        //定义一个list
        ObservableList<String> list = FXCollections.observableArrayList("A", "B", "C", "D", "E", "F", "G");

        Spinner<String> listSpinner = new Spinner<>(list);

        //设置递增，递减按钮的样式
        listSpinner.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL);

        hBox.getChildren().addAll(listSpinner);
        primaryStage.setScene(new Scene(hBox));
        primaryStage.setWidth(600);
        primaryStage.setHeight(500);
        primaryStage.show();
    }
}
